import {baseEffects, baseReducers, baseState} from "../../../../../models/baseModel";
import PageHelper from "utils/pageHelper";
import moment from "moment";

export default {
  namespace: 'testDataHistory',

  state: {
    ...baseState,
  },

  reducers: {
    ...baseReducers
  },

  effects: {

    ...baseEffects,

    * getPageInfo({payload}, {call, put}) {


      let result = [];
      for (let i = 0; i < 10; i++) {
        result.push({
          i: i,
          channel: "肌酐",
          result: "86.3",
          unit: "mmol/L",
          time: moment().format('YYYY-MM-DD HH:mm:ss'),
        });
      }

      yield put({
        type: 'list',
        payload: {
          data: PageHelper.wrapPage(result)
        }
      });
    },

    // 保存和修改
    * save({payload}, {put}) {

      yield put({
        type: 'baseSave',
        payload: {...payload, baseUrl: getBaseUrl()}
      });
    },


    // 删除 之后查询分页
    * delete({payload}, {call, put, select}) {

      yield put({
        type: 'baseDelete',
        payload: {...payload, baseUrl: getBaseUrl()}
      });
    },

    * getAll({payload}, {put, call}) {

      yield put({
        type: 'baseGetAll',
        payload: {...payload, baseUrl: getBaseUrl()}
      });
    }
  }

}

function getBaseUrl() {
  return "/area";
}

